{extend name="layout:base" /}
{block name="main_content"}
  <div class="page-content">
    <!--主题-->
    <?php if(!empty($current_page)): ?>
      <div class="page-header">
        <h1>
          您当前操作
          <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
            {$current_page.title|default=''}
          </small>
        </h1>
      </div>
    <?php endif; ?>
    <div class="row">
      <div class="col-xs-12">
        <form class="form-horizontal adminform" id="model-form" method="post" action="">
          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 
              Banner标题：<span class="red">*</span>
            </label>
            <div class="col-sm-10">
              <input type="text" name="title" placeholder="请输入Banner标题" class="col-xs-10 col-sm-5" value="{$banner.title|default=''}" required/>
            </div>
          </div>
          <div class="space-4"></div>
          
          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" for="form-field-1">
              封面图片：
            </label>
            <div class="col-sm-10">
              {:upload_image_id("wap_cover_id", 500, 170, $banner['wap_cover_id'])}
            </div>
          </div>
          <div class="space-4"></div>

          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" for="form-field-1">
              链接地址：
            </label>
            <div class="col-sm-10">
              <input type="text" name="link_url" placeholder="请输入链接地址，站外以址以http://开头" class="col-xs-10 col-sm-5" value="{$banner.link_url|default=''}"/>
            </div>
          </div>
          <div class="space-4"></div>

          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 显示状态：  </label>
            <div class="col-sm-10" style="padding-top:5px;">
              <input name="status" value="1" class="ace ace-switch ace-switch-4 btn-flat" type="checkbox" <?php if(isset($banner["status"]) && intval($banner["status"])){echo('checked="checked"');} ?> />
              <span class="lbl"></span>
            </div>
          </div>
          <div class="space-4"></div>

          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right"> 开始使用日期 </label>
            <div class="col-sm-10">
              <input type="text" name="start_time" id="date-timepicker1" placeholder="开始使用日期" class="col-xs-10 col-sm-5 datepicker" value="{$banner.start_time|format_show_time=###}">
            </div>
          </div>
          <div class="space-4"></div>
          <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right" for="form-field-2"> 结束使用日期 </label>
            <div class="col-sm-10">
              <input type="text" name="end_time" id="date-timepicker2" placeholder="结束使用日期" class="col-xs-10 col-sm-5 datepicker" value="{$banner.end_time|format_show_time=###}">
            </div>
          </div>
          <div class="space-4"></div>

          <div class="clearfix form-actions">
            <div class="col-md-offset-3 col-md-9">
              <?php if(isset($banner['id'])): ?>
                <input type="hidden" name="id" value="{$banner.id}">
              <?php endif; ?>
              <button class="btn btn-info" type="submit">
                <i class="ace-icon fa fa-check bigger-110"></i>
                保存
              </button>

              &nbsp; &nbsp; &nbsp;
              <button class="btn" type="reset">
                <i class="ace-icon fa fa-undo bigger-110"></i>
                重置
              </button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{/block}
{block name="page_js"}
  <script src="{$site_root}/static/plugins/jquery-validate/jquery.validate.min.js"></script>
  <script src="{$site_root}/static/admin/js/bootstrap-datetimepicker.js"></script>
  <script type="text/javascript">
    $("form#model-form").validate({
      rules:{
        "title":{
          required: true,
          minlength: 2,
          maxlength: 50
        }, "wap_cover_id":{
          min: 1
        }
      },
      messages:{
        "title":{
          required: "Banner标题不能为空",
          minlength: "Banner标题不能少于2个字符",
          maxlength: "Banner标题不能超过60个字符"
        }, "wap_cover_id":{
          min: "封面图片不能为空"
        }
      },
      errorClass: "help-inline input-error",
      errorElement: "span",
      highlight:function(element, errorClass, validClass) {
        $(element).parents('.form-group').addClass('has-error');
      },
      unhighlight: function(element, errorClass, validClass) {
        $(element).parents('.form-group').removeClass('has-error');
      },
      ignore: "",
      submitHandler: function(form){
        var $form = $(form);
        $.ajax({
          url: $form.attr("action"),
          type: $form.attr("method"),
          dataType: "JSON",
          data: $form.serialize(),
          success: function(data){
            if(data.code){
              location.href = data["url"];
            }else{
              alert(data["msg"]);
            }
          }, error: function () {
            alert("数据执行错误！");
          }
        });
      }
    });


    jQuery(function($) {
        $('#date-timepicker1').datetimepicker({
         icons: {
          time: 'fa fa-clock-o',
          date: 'fa fa-calendar',
          up: 'fa fa-chevron-up',
          down: 'fa fa-chevron-down',
          previous: 'fa fa-chevron-left',
          next: 'fa fa-chevron-right',
          today: 'fa fa-arrows ',
          clear: 'fa fa-trash',
          close: 'fa fa-times',
         },
             　minView: "month", //选择日期后，不会再跳转去选择时分秒 
      　　format: "yyyy-mm-dd 00:00:00", //选择日期后，文本框显示的日期格式 
      　　language: 'zh-CN', //汉化 
      　　autoclose:true //选择日期后自动关闭 
        }).next().on(ace.click_event, function(){
          $(this).prev().focus();
        });
        
        $('#date-timepicker2').datetimepicker({
         icons: {
          time: 'fa fa-clock-o',
          date: 'fa fa-calendar',
          up: 'fa fa-chevron-up',
          down: 'fa fa-chevron-down',
          previous: 'fa fa-chevron-left',
          next: 'fa fa-chevron-right',
          today: 'fa fa-arrows ',
          clear: 'fa fa-trash',
          close: 'fa fa-times',
         },
             　minView: "month", //选择日期后，不会再跳转去选择时分秒 
      　　format: "yyyy-mm-dd 23:59:59", //选择日期后，文本框显示的日期格式 
      　　language: 'zh-CN', //汉化 
      　　autoclose:true //选择日期后自动关闭 
        }).next().on(ace.click_event, function(){
          $(this).prev().focus();
        });
      });




  </script>
{/block}